var a = getApp();

Component({
    properties: {
        datas: {
            type: null
        },
        component_id: {
            type: null
        },
        U_tabcontrol: {
            type: null
        }
    },
    data: {
        emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
        wait_page: "",
        active: 1,
        status: 3,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        myConcern: "",
        announceList: "",
        broadcastlist: "",
        apiType: "AllLivelist",
        playBackData: "",
        allLivelistData: "",
        playBackShow: !1,
        myConcern_activitys1: [],
        myConcern_activitys2: [],
        allLivelistData_activitys1: [],
        allLivelistData_activitys2: [],
        recommendData_activitys1: [],
        recommendData_activitys2: [],
        broadcastlist_activitys1: [],
        broadcastlist_activitys2: [],
        announceList_activitys1: [],
        announceList_activitys2: [],
        playBackData_activitys1: [],
        playBackData_activitys2: [],
        recommendData: [],
        my_colOneHeight: 0,
        my_colTwoHeight: 0,
        re_colOneHeight: 0,
        re_colTwoHeight: 0,
        br_colOneHeight: 0,
        br_colTwoHeight: 0,
        an_colOneHeight: 0,
        an_colTwoHeight: 0,
        pl_colOneHeight: 0,
        pl_colTwoHeight: 0,
        all_colOneHeight: 0,
        all_colTwoHeight: 0
    },
    lifetimes: {
        attached: function() {},
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {
        this.data.U_tabcontrol ? (this.setData({
            active: "0"
        }), this.getRoomPage("0", this.data.datas)) : (this.setData({
            active: this.data.datas.choose_tab
        }), this.getRoomPage(this.data.datas.choose_tab, this.data.datas));
    },
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        getRoomPage: function(a, t) {
            t.list && this.setData({
                playBackShow: 1 == this.data.datas.record_id
            }), a && (this.setData({
                wait_page: a
            }), 0 == this.data.wait_page ? (this.data.all_colOneHeight = 0, this.data.all_colTwoHeight = 0, 
            this.data.datas.get_number && (t.list.data = t.list.data.slice(0, this.data.datas.get_number)), 
            this.setData({
                total_page: t.list.data ? t.list.last_page : 0,
                allLivelistData: t.list.data ? t.list.data : t.list,
                allLivelistData_activitys1: [],
                allLivelistData_activitys2: [],
                active: 0
            })) : 1 == this.data.wait_page ? (this.data.re_colOneHeight = 0, this.data.re_colTwoHeight = 0, 
            this.data.datas.get_number && (t.list = t.list.slice(0, this.data.datas.get_number)), 
            this.setData({
                total_page: 0,
                recommendData: t.list,
                recommendData_activitys1: [],
                recommendData_activitys2: [],
                active: 1
            })) : 2 == this.data.wait_page ? (this.data.apiType = "liveList", this.data.status = 3, 
            this.data.br_colOneHeight = 0, this.data.br_colTwoHeight = 0, this.data.datas.get_number && (t.list.data = t.list.data.slice(0, this.data.datas.get_number)), 
            this.setData({
                total_page: t.list.data ? t.list.last_page : 0,
                broadcastlist: t.list.data ? t.list.data : t.list,
                broadcastlist_activitys1: [],
                broadcastlist_activitys2: [],
                active: 2
            })) : 3 == this.data.wait_page ? (this.data.apiType = "liveList", this.data.status = 2, 
            this.data.an_colOneHeight = 0, this.data.an_colTwoHeight = 0, this.data.datas.get_number && (t.list.data = t.list.data.slice(0, this.data.datas.get_number)), 
            this.setData({
                total_page: t.list.data ? t.list.last_page : 0,
                announceList: t.list.data ? t.list.data : t.list,
                announceList_activitys1: [],
                announceList_activitys2: [],
                active: 3
            })) : 4 == this.data.wait_page && (this.data.apiType = "playBack", this.data.pl_colOneHeight = 0, 
            this.data.pl_colTwoHeight = 0, this.data.datas.get_number && (t.list.data = t.list.data.slice(0, this.data.datas.get_number)), 
            this.setData({
                total_page: t.list.data ? t.list.last_page : 0,
                playBackData: t.list.data ? t.list.data : t.list,
                playBackData_activitys1: [],
                playBackData_activitys2: [],
                active: 4
            })));
        },
        chunk: function(a, t) {
            for (var e = [], i = 0, s = a.length; i < s; i += t) e.push(a.slice(i, i + t));
            return e;
        },
        getLiveList: function(t) {
            var e = this, i = a.getNetAddresss("plugin.room.frontend.live-list.get-live-list");
            a._postNetWork({
                url: i,
                showToastIn: !1,
                data: {
                    status: t,
                    page: 1,
                    keyword: this.data.live_search
                },
                success: function(a) {
                    var i = a.data;
                    1 == i.result ? (e.data.datas.get_number && (i.data.data = i.data.data.slice(0, e.data.datas.get_number)), 
                    2 == t ? e.setData({
                        total_page: i.data.last_page,
                        announceList: i.data.data
                    }) : 3 == t && e.setData({
                        total_page: i.data.last_page,
                        broadcastlist: i.data.data
                    })) : wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        golivePage: function(a) {
            var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.status, i = a.currentTarget.dataset.memberid;
            1 == e ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + t + "&playerType=live"
            }) : wx.navigateTo({
                url: "/packageD/directSeeding/anchorDetail/anchorDetail?id=" + i
            });
        },
        goforeshow: function(a) {
            var t = a.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageD/directSeeding/foreshow/foreshow?id=" + t
            });
        },
        gopage: function(a) {
            var t = a.currentTarget.dataset.status, e = a.currentTarget.dataset.id, i = a.currentTarget.dataset.backid;
            1 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
            }) : 2 == t && wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
            });
        },
        golistPage: function(a) {
            var t = a.currentTarget.dataset.status, e = a.currentTarget.dataset.id, i = a.currentTarget.dataset.backid;
            3 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
            }) : 2 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/foreshow/foreshow?id=" + e
            }) : 4 == t && wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
            });
        },
        getplayBack: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.play-back");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page: 1,
                    keyword: this.data.live_search
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.data.datas.get_number && (e.data.data = e.data.data.slice(0, t.data.datas.get_number)), 
                    t.setData({
                        playBackData: e.data.data,
                        total_page: e.data.last_page
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        swichTabTItem: function(a) {
            var t = a.detail.index;
            this.setData({
                isLoadMore: !0,
                page: 1,
                total_page: 0,
                live_search: "",
                active: t
            }), 0 == t ? (this.data.apiType = "AllLivelist", this.getAllLivelist()) : 1 == t ? (this.data.apiType = "recommend", 
            this.getRecommend()) : 2 == t ? (this.data.apiType = "liveList", this.data.status = 3, 
            this.getLiveList(3)) : 3 == t ? (this.data.apiType = "liveList", this.data.status = 2, 
            this.getLiveList(2)) : 4 == t && (this.data.apiType = "playBack", this.getplayBack());
        },
        getAllLivelist: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-all-live-list");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page: 1,
                    keyword: this.data.live_search
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.data.datas.get_number && (e.data.data = e.data.data.slice(0, t.data.datas.get_number)), 
                    t.setData({
                        allLivelistData: e.data.data,
                        total_page: e.data.last_page
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        getRecommend: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-live-recommend");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    keyword: this.data.live_search
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.data.datas.get_number && (e.data = e.data.slice(0, t.data.datas.get_number)), 
                    t.setData({
                        recommendData: e.data
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        goPlayBackData: function(a) {
            var t = a.currentTarget.dataset.roomid, e = a.currentTarget.dataset.backid;
            wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + t + "&playerType=video&backid=" + e
            });
        },
        onImageError: function(a) {
            var t = a.target.dataset.index, e = a.target.dataset.seltype;
            console.log("图片加载发生错误"), this.onImageLoad({
                target: {
                    dataset: {
                        index: t,
                        seltype: e
                    }
                },
                detail: {
                    width: 2340,
                    height: 1080
                }
            });
        },
        onImageLoad: function(a) {
            var t = a.target.dataset.index, e = a.target.dataset.seltype, i = null, s = a.detail.width / a.detail.height;
            if ("myConcern" == e) {
                i = this.data.myConcern[t];
                var l = this.data.myConcern_activitys1, d = this.data.myConcern_activitys2;
                this.data.my_colOneHeight <= this.data.my_colTwoHeight ? (this.data.my_colOneHeight += 176 / s + 60, 
                l.push(i)) : (this.data.my_colTwoHeight += 176 / s + 60, d.push(i)), this.setData({
                    myConcern_activitys1: l,
                    myConcern_activitys2: d
                });
            } else if ("recommend" == e) {
                i = this.data.recommendData[t];
                var o = this.data.recommendData_activitys1, c = this.data.recommendData_activitys2;
                this.data.re_colOneHeight <= this.data.re_colTwoHeight ? (this.data.re_colOneHeight += 176 / s + 60, 
                o.push(i)) : (this.data.re_colTwoHeight += 176 / s + 60, c.push(i)), this.setData({
                    recommendData_activitys1: o,
                    recommendData_activitys2: c
                });
            } else if ("AllLivelist" == e) {
                i = this.data.allLivelistData[t];
                var n = this.data.allLivelistData_activitys1, r = this.data.allLivelistData_activitys2;
                this.data.all_colOneHeight <= this.data.all_colTwoHeight ? (this.data.all_colOneHeight += 176 / s + 60, 
                n.push(i)) : (this.data.all_colTwoHeight += 176 / s + 60, r.push(i)), this.setData({
                    allLivelistData_activitys1: n,
                    allLivelistData_activitys2: r
                });
            } else if ("liveList_1" == e) {
                i = this.data.broadcastlist[t];
                var g = this.data.broadcastlist_activitys1, h = this.data.broadcastlist_activitys2;
                this.data.br_colOneHeight <= this.data.br_colTwoHeight ? (this.data.br_colOneHeight += 176 / s + 60, 
                g.push(i)) : (this.data.br_colTwoHeight += 176 / s + 60, h.push(i)), this.setData({
                    broadcastlist_activitys1: g,
                    broadcastlist_activitys2: h
                });
            } else if ("liveList_2" == e) {
                i = this.data.announceList[t];
                var p = this.data.announceList_activitys1, v = this.data.announceList_activitys2;
                this.data.an_colOneHeight <= this.data.an_colTwoHeight ? (this.data.an_colOneHeight += 176 / s + 60, 
                p.push(i)) : (this.data.an_colTwoHeight += 176 / s + 60, v.push(i)), this.setData({
                    announceList_activitys1: p,
                    announceList_activitys2: v
                });
            } else if ("playBack" == e) {
                i = this.data.playBackData[t];
                var _ = this.data.playBackData_activitys1, u = this.data.playBackData_activitys2;
                this.data.pl_colOneHeight <= this.data.pl_colTwoHeight ? (this.data.pl_colOneHeight += 176 / s + 60, 
                _.push(i)) : (this.data.pl_colTwoHeight += 176 / s + 60, u.push(i)), this.setData({
                    playBackData_activitys1: _,
                    playBackData_activitys2: u
                });
            }
        },
        _getMoreData: function() {
            var t = this, e = {}, i = "", s = "";
            t.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
            "myConcern" == this.data.apiType ? (i = "plugin.room.frontend.live-list.get-live-concern", 
            e = {
                page: this.data.page
            }) : "AllLivelist" == t.data.apiType ? (i = "plugin.room.frontend.live-list.get-all-live-list", 
            e = {
                page: this.data.page
            }) : "playBack" == t.data.apiType ? (i = "plugin.room.frontend.live-list.play-back", 
            e = {
                page: this.data.page
            }) : (i = "plugin.room.frontend.live-list.get-live-list", e = {
                status: this.data.status,
                page: this.data.page
            }), e.keyword = this.data.live_search, s = a.getNetAddresss(i), a._postNetWork({
                url: s,
                showToastIn: !1,
                data: e,
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? "myConcern" == t.data.apiType ? t.setData({
                        isLoadMore: !0,
                        myConcern: t.data.myConcern.concat(e.data.data)
                    }) : "playBack" == t.data.apiType ? t.setData({
                        isLoadMore: !0,
                        playBackData: t.data.playBackData.concat(e.data.data)
                    }) : "AllLivelist" == t.data.apiType ? t.setData({
                        isLoadMore: !0,
                        allLivelistData: t.data.allLivelistData.concat(e.data.data)
                    }) : 2 == t.data.status ? t.setData({
                        isLoadMore: !0,
                        announceList: t.data.announceList.concat(e.data.data)
                    }) : 3 == t.data.status && t.setData({
                        isLoadMore: !0,
                        broadcastlist: t.data.broadcastlist.concat(e.data.data)
                    }) : t.setData({
                        page: t.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            }));
        }
    }
});